package com.itboye.ihomebank.key;

import android.graphics.drawable.BitmapDrawable;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.FrameLayout.LayoutParams;

import com.itboye.ihomebank.R;
import com.itboye.ihomebank.base.BaseOtherActivity;

/**
 * 发送钥匙
 * 
 * @author 余 焱
 * 
 */
public class ActivitySendKey extends BaseOtherActivity {

	ImageView send_key_finish;// 返回
	RelativeLayout send_key_xuanze;// 选择钥匙类型
	TextView send_key_xuan;// 钥匙类型

	LinearLayout send_key_kuang;// 选择框

	LinearLayout send_layout01;// 永久钥匙时候的界面
	EditText send_yaoshi, send_beizhu;// 永久钥匙时候的界面(住家账号,备注)
	TextView send_ok01;// 永久钥匙时候的界面(发送)

	LinearLayout send_layout02;// 期限钥匙时候的界面
	EditText send_yaoshi02, send_beizhu02;// 期限钥匙时候的界面(住家账号,备注)
	TextView send_start_time, send_stop_time;// 期限钥匙时候的界面(开始时间，结束时间)
	TextView send_ok02;// 期限钥匙时候的界面(发送)

	PopupWindow popupWindow;
	
	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.send_key_finish:
			finish();
			break;
		case R.id.send_key_xuanze:
			PuPoWindow(v);
			break;
		case R.id.send_key_yongjiu://永久钥匙
			popupWindow.dismiss();
			send_key_xuan.setText("永久");
			send_layout01.setVisibility(View.VISIBLE);
			send_layout02.setVisibility(View.GONE);
			
			break;
		case R.id.send_key_qixian://期限钥匙
			popupWindow.dismiss();
			send_key_xuan.setText("期限");
			send_layout01.setVisibility(View.GONE);
			send_layout02.setVisibility(View.VISIBLE);
			break;

		default:
			break;
		}

	}

	@Override
	protected int layout_id() {
		// TODO Auto-generated method stub
		return R.layout.activity_send_key;
	}

	@Override
	protected void onInitController() {
		// TODO Auto-generated method stub

	}

	@Override
	protected void onInit() {
		// TODO Auto-generated method stub

	}

	@Override
	protected void onReadIntent(Bundle bundle) {
		// TODO Auto-generated method stub

	}
	/**
	 * 钥匙搜索切换框
	 * @param v
	 */
	private void PuPoWindow(View v) {

		View view = LayoutInflater.from(this).inflate(
				R.layout.item_yaoshi_qiehuan, null);
		TextView send_key_yongjiu = (TextView) view.findViewById(R.id.send_key_yongjiu);
		TextView send_key_qixian = (TextView) view.findViewById(R.id.send_key_qixian);

		send_key_yongjiu.setOnClickListener(this);
		send_key_qixian.setOnClickListener(this);
		popupWindow = new PopupWindow(view, LayoutParams.WRAP_CONTENT,
				LayoutParams.WRAP_CONTENT);
		popupWindow.setOutsideTouchable(true);
		popupWindow.setBackgroundDrawable(new BitmapDrawable());
		popupWindow.showAsDropDown(v);
	}
}
